package hi_util

const (
	HI_LOG_LEVEL_INVAILD int8 = -1
)

type Hi_log_level struct {
	Val int8
}

func new_hi_log_level() *Hi_log_level {
	return &Hi_log_level{
		Val: HI_LOG_LEVEL_INVAILD,
	}
}

type hi_log_write func(level int8, log string)

type Hi_log_data struct {
	Level_info       Hi_log_level
	Level_trace      Hi_log_level
	Level_debug      Hi_log_level
	Level_alarm      Hi_log_level
	Level_warning    Hi_log_level
	Level_error      Hi_log_level
	Level_always_out Hi_log_level
	Write            hi_log_write
}

type Hi_log interface {
	Info(string)
	Trace(string)
	Debug(string)
	Warning(string)
	Error(string)
	Always_out(string)
	Level() *Hi_log_data
}

var hi_log_instance Hi_log

func Get_Instance() Hi_log {
	if nil == hi_log_instance {
		var log_data = New_hi_log()
		hi_log_instance = log_data
	}
	return hi_log_instance
}

func New_hi_log() *Hi_log_data {
	return &Hi_log_data{
		Level_info:       *new_hi_log_level(),
		Level_trace:      *new_hi_log_level(),
		Level_debug:      *new_hi_log_level(),
		Level_alarm:      *new_hi_log_level(),
		Level_warning:    *new_hi_log_level(),
		Level_error:      *new_hi_log_level(),
		Level_always_out: *new_hi_log_level(),
		Write:            func(level int8, log string) {},
	}
}
func (log *Hi_log_data) Info(msg string) {
	log.Write(log.Level_info.Val, msg)
}
func (log *Hi_log_data) Trace(msg string) {
	log.Write(log.Level_trace.Val, msg)
}
func (log *Hi_log_data) Debug(msg string) {
	log.Write(log.Level_debug.Val, msg)
}
func (log *Hi_log_data) Alarm(msg string) {
	log.Write(log.Level_alarm.Val, msg)
}
func (log *Hi_log_data) Warning(msg string) {
	log.Write(log.Level_warning.Val, msg)
}
func (log *Hi_log_data) Error(msg string) {
	log.Write(log.Level_error.Val, msg)
}
func (log *Hi_log_data) Always_out(msg string) {
	log.Write(log.Level_always_out.Val, msg)
}

func (log *Hi_log_data) Level() *Hi_log_data {
	return log
}
